package site.xuxingcan.xposedxiwang;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    private EditText mEditText;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mEditText = ((EditText) findViewById(R.id.ip));
        if (TextUtils.isEmpty(FileUtil.getInstance().getSettingModel().ip)) {
            mEditText.setText("");
        } else {
            mEditText.setText(FileUtil.getInstance().getSettingModel().ip);
        }
        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SettingModel settingModel = FileUtil.getInstance().getSettingModel();
                settingModel.ip = mEditText.getText().toString();
                FileUtil.getInstance().writeSetting(settingModel);
                Toast.makeText(MainActivity.this, "保存成功", Toast.LENGTH_SHORT).show();
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
